<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>申报任务审核-院学术委员会秘书处</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript"
            charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn {
        text-align: right;
    }
    #tableBox .layui-table-cell .layui-form-checkbox[lay-skin=primary] {
        top: 5px!important;
    }
</style>
<body>
<div>
    <div class="item">
        <img src="../img/chengguo.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">申报审核(院学术委员会秘书处)</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="layui-form" id="radioBox" style="margin-left: 12px;">
        <%--<div class="layui-input-block">--%>
        <input type="radio" name="status" lay-filter="status" checked value="0" title="未审核">
        <input type="radio" lay-filter="status" value="1" name="status" title="通过">
        <input type="radio" lay-filter="status" value="2" name="status" title="退回">
        <input type="radio" lay-filter="status" value="3" name="status" title="不通过">

        <%--</div>--%>
    </div>
    <div>
        <div class="btn">
            <button type="button" class="layui-btn add layui-btn-sm " id="approval" style="">
                <i class="layui-icon layui-icon-ok"></i>
                通过
            </button>
                <button type="button" class="layui-btn add layui-btn-sm " id="back" style="">
                <i class="layui-icon layui-icon-list"></i>
                退回
                </button>
            <button type="button" class="layui-btn add layui-btn-sm " id="disapproval" style="">
                <i class="layui-icon layui-icon-close"></i>
                不通过
            </button>

            <button type="button" class="layui-btn immp layui-btn-sm " id="export" style="margin-right: 15px">
                <i class="layui-icon layui-icon-export"></i>
                导出
            </button>
        </div>

    </div>
    <div id="tableBox">
        <table class="layui-hide" id="Settlement" lay-filter="SettlementFilter"></table>
    </div>
</div>
</body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">申核</a>
    <a class="layui-btn layui-btn-xs" lay-event="look">查看</a>
</script>
<script type="text/html" id="xuhao">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<script>
    var settlementTable;
    layui.use(['table', 'layer', 'form','laydate'], function () {
        var table = layui.table
            , layer = layui.layer
            , form = layui.form
            ,laydate=layui.laydate;
        gettable("/ResultManagement/list?pageSize=10&useFlag=true")
        //监听行工具事件
        table.on('tool(SettlementFilter)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                window.location.href='/rpmPlan/auditdirector?type=1&btype=edit&userId='+data.userId+'&planId='+data.planId+'&trId='+data.trId;
            }
            if(obj.event === 'look'){
                window.location.href='/rpmPlan/auditdirector?type=1&btype=look&userId='+data.userId+'&planId='+data.planId+'&trId='+data.trId;
            }
        });
        form.on('radio(status)', function (data) {
            //未审核
            if(data.value == "0" || data.value == 0){
                $("#approval").css("display","");
                $("#disapproval").css("display","");
                $("#back").css("display","");
                gettable("/ResultManagement/list?pageSize=10&useFlag=true")
            }
            //通过
            if(data.value == "1" || data.value == 1){
                $("#approval").css("display","none");
                $("#disapproval").css("display","none");
                $("#back").css("display","none");
                gettable("/ResultManagement/gradingList?pageSize=10&useFlag=true")
            }
            //退回
            if(data.value == "2" || data.value == 2){
                $("#approval").css("display","none");
                $("#disapproval").css("display","none");
                $("#back").css("display","none");
                gettable("/ResultManagement/list?pageSize=10&useFlag=true&page=1&limit=10&type=1")
            }
            //不通过
            if(data.value == "3" || data.value == 3){
                $("#approval").css("display","none");
                $("#disapproval").css("display","none");
                $("#back").css("display","none");
                gettable("/ResultManagement/gradingList?pageSize=10&useFlag=true&page=1&limit=10&type=2")
            }
        });
        form.render();
        //提交操作
        $("#apply").click(function(){

        })
        //查询操作
        $("#search").click(function(){

        })
        //通过操作
        $("#approval").click(function(){
            var data = table.checkStatus('Settlement').data;
            if (data.length == 1) {
                var topicId = "";
                var trId = "";
                for(var i=0;i<data.length;i++){
                    trId += data[i].trId;
                    topicId += data[i].trTopicId;
                }
                layer.confirm('是否确认通过', {
                    btn: ['确认', '取消'],
                    icon: 7,
                    title: "系统提示"
                }, function () {
                    $.ajax({
                        type: "post",
                        url: "/ResultManagement/examination",
                        dataType: "json",
                        data: {
                            trId: trId,
                            topicId:topicId,
                            status:2
                        },
                        success: function (res) {
                            if (res.flag) {
                                layer.msg("通过提交成功");
                                settlementTable.reload();
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                }, function () {
                    parent.layer.closeAll();
                });
            }else{
                layer.msg("请选择一条进行审核");
                return false;
            }
        })
        //不通过操作
        $("#disapproval").click(function(){
            var data = table.checkStatus('Settlement').data;
            if (data.length == 1) {
                var topicId = "";
                var trId = "";
                for(var i=0;i<data.length;i++){
                    trId += data[i].trId;
                    topicId += data[i].trTopicId;
                }
                layer.confirm('是否确认不通过', {
                    btn: ['确认', '取消'],
                    icon: 7,
                    title: "系统提示"
                }, function () {
                    $.ajax({
                        type: "post",
                        url: "/ResultManagement/examination",
                        dataType: "json",
                        data: {
                            trId: trId,
                            topicId:topicId,
                            status:3
                        },
                        success: function (res) {
                            if (res.flag) {
                                layer.msg("不通过提交成功");
                                settlementTable.reload();
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                }, function () {
                    layer.closeAll();
                });
            } else{
                layer.msg("请选择一条进行审核");
                return false;
            }
        })
        //退回操作
        $("#back").click(function(){
            var data = table.checkStatus('Settlement').data;
            if (data.length == 1) {
                var topicId = data[0].trTopicId;
                var trId = data[0].trId;
                layer.open({
                    type: 1,
                    title:'退回意见',
                    btn: ['确定', '取消'],
                    shade: 0.5,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['40%', '50%'],
                    content: '<div id="cont" style="margin: 10px">\n' +
                    '        <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <div class="layui-inline">\n' +
                    '                    <div class="layui-form-item layui-form-text">\n' +
                    '                        <label class="layui-form-label">退回意见:</label>\n' +
                    '                        <div class="layui-input-inline">\n' +
                    '                            <textarea placeholder="请输入内容" id="areatext" class="layui-textarea"  name="teacheerOpinion"></textarea>\n' +
                    '                        </div>\n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '        </form>\n' +
                    '    </div>',
                    yes:function (index) {
                        layer.close(index);
                        $.ajax({
                            type: "post",
                            url: "/ResultManagement/updateBack",
                            dataType: "json",
                            data: {
                                trId: trId,
                                topicId:topicId,
                                message:$("#areatext").val()
                            },
                            success: function (res) {
                                if (res.flag) {
                                    layer.msg('退回成功！', {icon: 1});
                                } else {
                                    layer.msg(res.msg);
                                }
                                settlementTable.reload();
                            }
                        })
                    }
                })
            }else{
                layer.msg("请选择一条进行退回。");
                return false;
            }
        })
        //导出操作
        $("#export").click(function(){
            var txt = $("#radioBox").find(".layui-form-radioed div").html();
            if(txt == "未审核"){
                var type = "1"
            }
            if(txt == "通过"){
                var type = "2"
            }
            if(txt == "退回"){
                var type = "3"
            }
            if(txt == "不通过"){
                var type = "4"
            }
            window.location.href = '/ResultManagement/examineExport?type='+type
        })
        function gettable(url) {
            settlementTable = table.render({
                elem: '#Settlement'
                ,url:url
                , cols: [[
                    {type:'checkbox'},
                    {field:'numbers', title: '序号', align: 'center',templet:"#xuhao"}
                    ,{field:'planName', title: '计划名称', align: 'center'}
                    ,{field:'deptName', title: '科室', align: 'center'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                    ,{field:'userName', title: '姓名', align: 'center'}
                    ,{field:'filingTime', title: '备案时间', align: 'center'}
                    ,{field:'xszz', title: '学术著作(数)', align: 'center'}
                    ,{field:'xslw', title: '学术论文(数)', align: 'center'}
                    ,{field:'xsltztfy', title: '学术论坛主题发言(数)', align: 'center'}
                    ,{field:'jtcg', title: '结题成果(数)', align: 'center'}
                    ,{field:'pxhj', title: '评选获奖(数)', align: 'center'}
                    ,{field:'trOther', title: '认定(数)', align: 'center',templet:function (d) {
                            if(d.trOther == undefined || d.trOther == "undefined" || d.trOther == "" || d.trOther == null){
                                d.trOther = "无"
                            }else{
                                d.trOther = d.trOther;
                            }
                            var str= d.xszz + d.xslw + d.xsltztfy + d.jtcg + d.pxhj + "/" + d.trOther;
                            return str
                        }}
                    , {field: 'type',width:130, title: '审核', toolbar: '#barDemo'}
                ]],
                page:true
                ,parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code": 0, //解析接口状态
                        "count": res.totleNum, //解析数据长度
                        "data": res.obj //解析数据列表
                    }
                },
                done:function (res) {

                }
            });
        }
    })
    // function  returnPraise(d) {
    //     var xszz = Number(d.xszz);
    //     var xslw = Number(d.xslw);
    //     var xsltztfy = Number(d.xsltztfy);
    //     var jtcg = Number(d.jtcg);
    //     var pxhj = Number(d.pxhj);
    //     var num = xszz + xslw + xsltztfy + jtcg + pxhj;
    //     if(xszz >1 && xslw >1 && xsltztfy >1 && jtcg >1 && pxhj >1){
    //
    //     }
    //
    // }
</script>
</html>

</body>
</html>
